<template>
  <div>
    <ZgEdit
      ref="dialog"
      :view="{ width: '50%', top: '5%', title: '调整授信额度'}"
      :columns="columns"
      :formulas="formulas"
      :inputClick="inputClick"
      validUrl=""
      saveUrl=""
      @ok="onOk">
    </ZgEdit>
  </div>
</template>
<script>
export default {
   props: {
      type: {
        type: String,
        default: 'add'
      }
    },
    data () {
    return {
      obj: null,
      columns: [
        { name: '融资企业', code: 'name1', compType: '单行文本', isNeed: false, offset: 0, span: 12, defaultVal: '测试企业1', regex: '', errorMsg: '', disabled: true },
        { name: '授信编号', code: 'name2', compType: '单行文本', isNeed: false, offset: 0, span: 12, defaultVal: '258291', regex: '', errorMsg: '', disabled: true },
        { name: '授信批准日期', code: 'name3', compType: '单行文本', isNeed: false, offset: 0, span: 12, defaultVal: '2026-01', regex: '', errorMsg: '', disabled: true },
        { name: '授信类型', code: 'name4', compType: '单行文本', isNeed: false, offset: 0, span: 12, defaultVal: '综合授信', regex: '', errorMsg: '', disabled: true },
        { name: '授信产品', code: 'text', compType: '文本', isNeed: false, offset: 0, span: 24, defaultVal: '浦发银承', disabled: true },
        { name: '调整钱授信额', code: 'name5', compType: '单行文本', isNeed: false, offset: 0, span: 12, defaultVal: '10000000', regex: '', errorMsg: '', disabled: true },
        { name: '', code: 'text6', compType: '文本', isNeed: false, offset: 0, span: 24, defaultVal: '', disabled: true },
        { name: '可以用授信余额', code: 'name7', compType: '单行文本', isNeed: false, offset: 0, span: 12, defaultVal: '10000000', regex: '', errorMsg: '', disabled: true },
        { name: '调整后授信额', code: 'name8', compType: '单行文本', isNeed: false, offset: 0, span: 12, defaultVal: '', regex: '', errorMsg: '' }
      ],
      formulas: [
        { triggerMode: '初始化时', name: '公式1', content: 'console.log("init");' },
        { triggerMode: '数据变化时', name: '公式2', content: 'console.log("update");' },
        { triggerMode: '提交时', name: '公式3', content: 'console.log("submit");' }
      ]
    }
  },
  methods: {
    open (json) {
      this.obj = Object.assign({}, this.obj, json || {})
      this.$refs.dialog.open()
    },
    onOk () {
      this.obj = null
      this.$refs.dialog.close()
      this.$emit('ok')
    },
    inputClick (t) {
      alert(JSON.stringify(t))
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
